import request from '@/utils/request';
import type { responseData,responseAttrData,attr} from './model/index';
//请求地址枚举
enum API {
    //一级分类接口地址
    c1 = "/admin/product/getCategory1",
    //二级分类接口的地址
    c2 = "/admin/product/getCategory2/",
    //三级分类的接口地址
    c3 = "/admin/product/getCategory3/",
    //获取某一个三级分类下平台属性与属性值
    attrList = "/admin/product/attrInfoList/",
    //添加一个新的属性与修改一个已有属性的接口地址
    addOrUpdateAttr="/admin/product/saveAttrInfo",
    //删除属性
    removeAttr="/admin/product/deleteAttr/"
}
//一级分类的请求函数
export const reqC1 = () => request.get<any, responseData>(API.c1);
//二级分类的请求函数
export const reqC2 = (category1Id: number | string) => request.get<any, responseData>(API.c2 + category1Id);
//三级分类的请求函数
export const reqC3 = (category2Id: number | string) => request.get<any, responseData>(API.c3 + category2Id);
//获取某一个三级分类下平台属性与属性值
export const reqAttrList = (category1Id: any, category2Id: any, category3Id: any) => request.get<any,responseAttrData>(API.attrList + `${category1Id}/${category2Id}/${category3Id}`);
//添加或者修改属性的接口函数
export const reqAddOrUpdateAttr = (data:attr)=>request.post<any,any>(API.addOrUpdateAttr,data);
//删除平台属性的接口函数
export const reqRemoveAttr = (attrId:number)=>request.delete<any,any>(API.removeAttr+attrId);